package com.akk.module.avs.service;

import com.akk.module.avs.entity.City;
import com.akk.module.avs.entity.CityExample;
import com.akk.module.avs.entity.Province;
import com.akk.module.avs.entity.ProvinceExample;
import com.akk.module.avs.mapper.CityMapper;
import com.akk.module.avs.mapper.ProvinceMapper;
import com.akk.module.avs.mapper.dao.ProvinceDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CityService {

    @Autowired
    private CityExample cityExample;

    @Autowired
    private CityMapper cityMapper;

    @Autowired
    private ProvinceExample provinceExample;

    @Autowired
    private ProvinceMapper provinceMapper;

    @Autowired
    private ProvinceDao provinceDao;

    public List<Province> allProvinces(){
//        provinceExample.clear();
//        provinceExample.createCriteria();
//        List<Map<String,Object>> list = new ArrayList<>();
//        List<Province> provinces = provinceMapper.selectByExample(provinceExample);
        return provinceDao.selectProvince();
    }

    public List<City> allCitys(){
        cityExample.clear();
        cityExample.createCriteria();
        return cityMapper.selectByExample(cityExample);
    }

    public List<City> cityByProvince(String provinceNo){
        cityExample.clear();
        cityExample.createCriteria().andCityProidEqualTo(provinceNo);
        return cityMapper.selectByExample(cityExample);
    }

}
